﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:loc="clr-namespace:AscendViewer">

	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="ContentNode.xaml"/>
	</ResourceDictionary.MergedDictionaries>
	
	<DataTemplate DataType="{x:Type loc:ContentExplorerViewModel}">
		<!-- Content explorer -->
		<Expander DockPanel.Dock="Left" ExpandDirection="Right" Margin="0,25,0,0" IsExpanded="{Binding IsExpanded}">
			<Expander.Header>
				<Label Content="Content Explorer" Foreground="White" Padding="0" Margin="2,5">
					<Label.LayoutTransform>
						<RotateTransform Angle="-90"/>
					</Label.LayoutTransform>
				</Label>
			</Expander.Header>

			<!-- Grid for content and resizer -->
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="225" MinWidth="55"/>
					<ColumnDefinition Width="9"/>
					<ColumnDefinition Width="*"/>
				</Grid.ColumnDefinitions>

				<!-- Explorer content -->
				<Border Grid.Column="0" BorderBrush="{DynamicResource ExpanderButtonBackgroundBrush}"
					BorderThickness="0,1,1,1" Margin="0,0,-5,0" CornerRadius="0,2,2,0">
					<Border.Background>
						<SolidColorBrush Color="#F5F5F5" Opacity="0.95"/>
					</Border.Background>

					<Grid>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto"/>
							<RowDefinition Height="*" MinHeight="25"/>
							<RowDefinition Height="11"/>
							<RowDefinition Height="Auto"/>
						</Grid.RowDefinitions>

						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						
						<!-- Explorer header -->
						<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding FileName}" Foreground="DimGray"
								   FontWeight="SemiBold" Margin="5,0,5,-10" HorizontalAlignment="Left"
								   VerticalAlignment="Center" FontSize="14"/>
						
						<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
							<Button Content="++" Command="{Binding ExpandAllCommand}" Padding="2,-2,2,0" Width="22"
									HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,5,5,0"
									HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
									ToolTip="Expand all content"/>
							<Button Content="--" Command="{Binding CollapseAllCommand}" Padding="2,-2,2,0" Width="22"
									HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,5,5,0"
									HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
									ToolTip="Collapse all content"/>
						</StackPanel>

						<!-- Content tree -->
						<ScrollViewer x:Name="PART_ContentTree" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Content="{Binding RootNode}"
									  HorizontalContentAlignment="Left" VerticalContentAlignment="Top" Margin="0,5,0,0"
									  HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"/>
						
						<!-- Splitter -->
						<GridSplitter x:Name="PART_Splitter" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Background="#E0E0E0"
									  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="3"/>
						
						<!-- Detail area -->
						<ScrollViewer x:Name="PART_Details" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
									  HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
							<Grid VerticalAlignment="Top">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto"/>
									<RowDefinition Height="*"/>
								</Grid.RowDefinitions>
								
								<!-- Transform details -->
								<Grid Grid.Row="1" TextBlock.Foreground="DimGray" Margin="5,0,5,5" HorizontalAlignment="Left">
									<Grid.RowDefinitions>
										<RowDefinition/>
										<RowDefinition/>
										<RowDefinition/>
										<RowDefinition/>
										<RowDefinition/>
									</Grid.RowDefinitions>
								
									<Grid.ColumnDefinitions>
										<ColumnDefinition/>
										<ColumnDefinition/>
										<ColumnDefinition/>
										<ColumnDefinition/>
									</Grid.ColumnDefinitions>
								
									<!-- Headers -->
									<TextBlock Text="Transform" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Left"
											   Margin="0,2" FontStyle="Italic" FontWeight="SemiBold"/>
									<TextBlock Text="Position" Grid.Row="2" Grid.Column="0" Margin="5,2" FontWeight="SemiBold"
											   HorizontalAlignment="Right"/>
									<TextBlock Text="Rotation" Grid.Row="3" Grid.Column="0" Margin="5,2" FontWeight="SemiBold"
											   HorizontalAlignment="Right"/>
									<TextBlock Text="Scale" Grid.Row="4" Grid.Column="0" Margin="5,2" FontWeight="SemiBold"
											   HorizontalAlignment="Right"/>
									<TextBlock Text="X" Grid.Row="1" Grid.Column="1" Margin="5,2" FontWeight="SemiBold"
											   Foreground="#DD0000" HorizontalAlignment="Center"/>
									<TextBlock Text="Y" Grid.Row="1" Grid.Column="2" Margin="5,2" FontWeight="SemiBold"
											   Foreground="#0000DD" HorizontalAlignment="Center"/>
									<TextBlock Text="Z" Grid.Row="1" Grid.Column="3" Margin="5,2" FontWeight="SemiBold"
											   Foreground="#00AA00" HorizontalAlignment="Center"/>
								
									<!-- Values -->
									<TextBlock Text="{Binding SelectedContentNode.Data.X, StringFormat=0.0000}" Grid.Row="2" Grid.Column="1"
											   Margin="5,2" HorizontalAlignment="Center"/>
									<TextBlock Text="{Binding SelectedContentNode.Data.Y, StringFormat=0.0000}" Grid.Row="2" Grid.Column="2"
											   Margin="5,2" HorizontalAlignment="Center"/>
									<TextBlock Text="{Binding SelectedContentNode.Data.Z, StringFormat=0.0000}" Grid.Row="2" Grid.Column="3"
											   Margin="5,2" HorizontalAlignment="Center"/>
									<TextBlock Text="{Binding SelectedContentNode.Data.AngleX, StringFormat=0.0000°}" Grid.Row="3" Grid.Column="1"
											   Margin="5,2" HorizontalAlignment="Center"/>
									<TextBlock Text="{Binding SelectedContentNode.Data.AngleY, StringFormat=0.0000°}" Grid.Row="3" Grid.Column="2"
											   Margin="5,2" HorizontalAlignment="Center"/>
									<TextBlock Text="{Binding SelectedContentNode.Data.AngleZ, StringFormat=0.0000°}" Grid.Row="3" Grid.Column="3"
											   Margin="5,2" HorizontalAlignment="Center"/>
									<TextBlock Text="{Binding SelectedContentNode.Data.ScaleX, StringFormat=0.0000}" Grid.Row="4" Grid.Column="1"
											   Margin="5,2" HorizontalAlignment="Center"/>
									<TextBlock Text="{Binding SelectedContentNode.Data.ScaleY, StringFormat=0.0000}" Grid.Row="4" Grid.Column="2"
											   Margin="5,2" HorizontalAlignment="Center"/>
									<TextBlock Text="{Binding SelectedContentNode.Data.ScaleZ, StringFormat=0.0000}" Grid.Row="4" Grid.Column="3"
											   Margin="5,2" HorizontalAlignment="Center"/>
								</Grid>
							</Grid>
						</ScrollViewer>
					</Grid>
				</Border>

				<!-- Resizing splitter -->
				<GridSplitter Grid.Column="1" Background="Transparent" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
			</Grid>
		</Expander>
		
		<DataTemplate.Triggers>
			<DataTrigger Binding="{Binding SelectedContentNode.Type}" Value="{x:Type loc:ArmatureContentNodeViewModel}">
				<Setter TargetName="PART_Splitter" Property="Visibility" Value="Collapsed"/>
				<Setter TargetName="PART_Details" Property="Visibility" Value="Collapsed"/>
				<Setter TargetName="PART_ContentTree" Property="Grid.RowSpan" Value="3"/>
			</DataTrigger>
			<DataTrigger Binding="{Binding SelectedContentNode}" Value="{x:Null}">
				<Setter TargetName="PART_Splitter" Property="Visibility" Value="Collapsed"/>
				<Setter TargetName="PART_Details" Property="Visibility" Value="Collapsed"/>
				<Setter TargetName="PART_ContentTree" Property="Grid.RowSpan" Value="3"/>
			</DataTrigger>
		</DataTemplate.Triggers>
	</DataTemplate>
</ResourceDictionary>